
package com.niit.service.impl;

import com.niit.entity.Orders;
import com.niit.mapper.OrdersMapper;


import com.niit.service.OrdersService;
import com.niit.utils.Result;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (Orders)表服务实现类
 *
 * @author makejava
 * @since 2024-06-17 22:55:39
 */
@Service("ordersService")
public class OrdersServiceImpl implements OrdersService {
    @Resource
    private OrdersMapper ordersMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Result queryById(Integer id) {
        return Result.ok().setData(this.ordersMapper.queryById(id));
    }

    /**
     * 全查询
     *
     * @param orders 筛选条件
     * @return 查询结果
     */
    @Override
    public Result queryAll(Orders orders) {
        return Result.ok().setData(this.ordersMapper.queryAll(orders));
    }

    /**
     * 新增数据
     *
     * @param orders 实例对象
     * @return 实例对象
     */
    @Override
    public Result insert(Orders orders) {
        this.ordersMapper.insert(orders);
        return Result.ok().setData(orders);
    }

    /**
     * 修改数据
     *
     * @param orders 实例对象
     * @return 实例对象
     */
    @Override
    public Result update(Orders orders) {
        this.ordersMapper.update(orders);
        return Result.ok().setData(this.queryById(orders.getId()));
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public Result deleteById(Integer id) {
        boolean del = this.ordersMapper.deleteById(id) > 0;
        return Result.ok().setData(del);
    }
}

